import React from "react";
import SizeChanger from "./sizeChanger";
import { prefixCls } from "../constant";

export interface PageSizeOptionsProps {
  options: { label: string; value: string }[];
  onChange: (pageSize: number) => void;
  value: number;
}

const PageSizeOptions: React.VFC<PageSizeOptionsProps> = (props) => {
  const { value, onChange, options } = props;
  const classname = `${prefixCls}-options-item`;

  const onOptionsChange = (v: any) => {
    onChange && onChange(parseInt(v));
  };

  return (
    <li className={classname}>
      <SizeChanger
        options={options}
        onChange={onOptionsChange}
        value={value.toString()}
        className=""
      />
    </li>
  );
};

export default PageSizeOptions;
